#!/usr/bin/env python

import pygame
import os
import logfile

class GfxManager:
    def __init__( self, log ):
        self.images = {}
        self.log = log
        return
    
    def load_image( self, file, key ):
        if os.path.exists(file)==False:
            self.log.write( "Cannot load image from nonexistent file {0}".format(file) )
            return
        try:
            self.images[key] = pygame.image.load( file )
        except IOError as (errno, strerror):
            self.log.write( "I/O error({0}): {1}".format(errno, strerror) )
        return
    
    def image( self, key ):
        if self.images.has_key(key):
            return self.images[key]
        else:
            return None    
        
